After completing this lesson, you’ll be able to:
You are continuing to work with the city parks data. You've been asked to find the average size of parks in each neighborhood. You can use the Group By parameter with an existing workspace to do this task.
1) Start FME Workbench
Start FME Workbench (2023.0 or later) and open the starting workspace. This workspace calculates the total area of all parks in the city using the StatisticsCalculator.
You can view the total area by running the workspace and inspecting the AttributeRenamer Output port. AverageParkArea is 70,248 m² for the entire dataset:
Remember that you can view the units for area or length calculations by checking the coordinate system of your data using the Feature Information Window. See View Information about a Specific Feature for more details.
2) Set Group By in the StatisticsCalculator
Changing the workspace to calculate the park area by neighborhood is straightforward. View the parameters for the StatisticsCalculator transformer. Check Group Processing and click the '...' button beside the Group By parameter. Select the attribute called Neighborhood:
Click OK/Apply to apply the changes to the transformer.
Older versions of FME had a Cumulative output port for the StatisticsCalculator. If you wish to calculate a cumulative or running statistic, which is updated each feature, check Advanced - Output Cumulative Results. This method can be useful if you have to determine when a cumulative sum, count, or mean surpasses a certain threshold value. In that case, you would need to combine the output of the StatisticsCalculator Cumulative port with a filtering transformer like a Tester.
3) Run the Workspace
Click on the StatisticsCalculator and then click on Run To This. Inspect the Summary output port in Visual Preview. The Summary output port creates a summarized table of the statistics you are calculating.
You should see that each neighborhood now has its own value for ParkArea.mean (renamed to AverageParkArea by the AttributeRenamer):